using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.IO;
using System.Runtime.InteropServices;

namespace Microsoft.WowAddonStudio.FrameXml.Services
{
	[Guid("B49111D7-8194-400b-B5D4-48B5454130E0")]
	public interface IFrameXmlComponentSerializationService
	{
		/// <summary>
		/// Creates a new <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/>.
		/// </summary>
		/// <returns>
		/// A new <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/>.
		/// </returns>
		SerializationStore CreateStore();

		/// <summary>
		/// Deserializes the given store to produce a collection of objects.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to deserialize.</param>
		/// <returns>
		/// A collection of objects created according to the stored state.
		/// </returns>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> does not contain data in a format the serialization container can process.</exception>
		ICollection Deserialize(SerializationStore store);

		/// <summary>
		/// Deserializes the given store and populates the given <see cref="T:System.ComponentModel.IContainer"/> with deserialized <see cref="T:System.ComponentModel.IComponent"/> objects.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to deserialize.</param>
		/// <param name="container">The <see cref="T:System.ComponentModel.IContainer"/> to which <see cref="T:System.ComponentModel.IComponent"/> objects will be added.</param>
		/// <returns>
		/// A collection of objects created according to the stored state.
		/// </returns>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="container"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> does not contain data in a format the serialization container can process.</exception>
		ICollection Deserialize(SerializationStore store, IContainer container);

		/// <summary>
		/// Deserializes the given <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to the given container, optionally applying default property values.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to deserialize.</param>
		/// <param name="container">The container to which <see cref="T:System.ComponentModel.IComponent"/> objects will be added.</param>
		/// <param name="validateRecycledTypes">true to guarantee that the deserialization will only work if applied to an object of the same type.</param>
		/// <param name="applyDefaults">true to indicate that the default property values should be applied.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="container"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> does not contain data in a format the serialization container can process.</exception>
		void DeserializeTo(SerializationStore store, IContainer container, bool validateRecycledTypes,
		                   bool applyDefaults);

		/// <summary>
		/// Loads a <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> from a stream.
		/// </summary>
		/// <param name="stream">The <see cref="T:System.IO.Stream"/> from which the store will be loaded.</param>
		/// <returns>
		/// A new <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> instance.
		/// </returns>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="stream"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="stream"/> does not contain data saved by a previous call to <see cref="M:System.ComponentModel.Design.Serialization.SerializationStore.Save(System.IO.Stream)"/>.</exception>
		SerializationStore LoadStore(Stream stream);

		/// <summary>
		/// Serializes the given object to the given <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/>.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to which the state of <paramref name="value"/> will be written.</param>
		/// <param name="value">The object to serialize.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="value"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> is closed, or <paramref name="store"/> is not a supported type of serialization store. Use a store returned by <see cref="M:System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore"/>.</exception>
		void Serialize(SerializationStore store, object value);

		/// <summary>
		/// Serializes the given object, accounting for default property values.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to which the state of <paramref name="value"/> will be serialized.</param>
		/// <param name="value">The object to serialize.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="value"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> is closed, or <paramref name="store"/> is not a supported type of serialization store. Use a store returned by <see cref="M:System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore"/>.</exception>
		void SerializeAbsolute(SerializationStore store, object value);

		/// <summary>
		/// Serializes the given member on the given object.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to which the state of <paramref name="member"/> will be serialized.</param>
		/// <param name="owningObject">The object to which <paramref name="member"/> is attached.</param>
		/// <param name="member">A <see cref="T:System.ComponentModel.MemberDescriptor"/> specifying the member to serialize.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="value"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> is closed, or <paramref name="store"/> is not a supported type of serialization store. Use a store returned by <see cref="M:System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore"/>.</exception>
		void SerializeMember(SerializationStore store, object owningObject, MemberDescriptor member);

		/// <summary>
		/// Serializes the given member on the given object, accounting for the default property value.
		/// </summary>
		/// <param name="store">The <see cref="T:System.ComponentModel.Design.Serialization.SerializationStore"/> to which the state of <paramref name="member"/> will be serialized.</param>
		/// <param name="owningObject">The object to which <paramref name="member"/> is attached.</param>
		/// <param name="member">The member to serialize.</param>
		/// <exception cref="T:System.ArgumentNullException">
		/// 	<paramref name="store"/> or <paramref name="value"/> is null.</exception>
		/// <exception cref="T:System.InvalidOperationException">
		/// 	<paramref name="store"/> is closed, or <paramref name="store"/> is not a supported type of serialization store. Use a store returned by <see cref="M:System.ComponentModel.Design.Serialization.CodeDomComponentSerializationService.CreateStore"/>.</exception>
		void SerializeMemberAbsolute(SerializationStore store, object owningObject, MemberDescriptor member);

		void DeserializeTo(SerializationStore store, IContainer container);
		void DeserializeTo(SerializationStore store, IContainer container, bool validateRecycledTypes);
	}
}